package com.mebs.edi.datalayer.jpa;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import com.mebs.edi.datalayer.VendorDao;
import com.mebs.model.Vendor;

public class JpaVendorDao extends JpaGenericDao implements VendorDao {

	public Vendor getVendor(String vendorName) {
		EntityManager em = getEntityManager();
		
		TypedQuery<Vendor> query = em
			.createQuery("from Vendor v where v.name = :vendorName", Vendor.class)
			.setParameter("vendorName", vendorName);
		Vendor vendor = query.getSingleResult();
		
		return vendor;
	}
	
	public Vendor getById(Long id) {
		EntityManager em = getEntityManager();
		
		Vendor vendor = em.find(Vendor.class, id);
		return vendor;
	}

}
